|
|
|
|
|
|
|
Not too long ago, memory was quite expensive, and this 16-color configuration was common. As memory prices dropped, more sophisticated color models became more popular. One model that is still popular uses a table of 256 color entries. The model uses 8 bits to store the index of each pixel in the table. If your monitor is 640 by 480 pixels, graphic memory uses 640 * 480 * 1 = 307,200 bytes or 300KB of memory. |
|
|
|
|
|
|
|
|
Recently, even more memory-intensive color models became common. Many computers can use 16 or 24 bits to describe each pixel's value, and some even use 32 bits. These models do not use color tables. Instead, the bits for each pixel describe the pixel's color directly. In 24-bit color, for example, 8 bits are used to describe each of the pixel's red, green, and blue color components. |
|
|
|
|
|
|
|
|
This is almost exactly the same way Visual Basic's RGB function works. Suppose you want a pixel to have color components r, g, and b. The value RGB(r, g, b) is a long integer containing the bits in the values r, g, and b. |
|
|
|
|
|
|
|
|
You can represent a value between 0 and 255 using two hexadecimal digits. For instance, the value 0 is &H00, and the value 255 is &HFF. That makes it easy to represent a color's numeric value using hexadecimal. If a pixel's component values are RR, GG, and BB in hexadecimal, the pixel's numeric value is &HBBGGRR. In fact, this is the value given by the RGB function. |
|
|
|
|
|
|
|
|
As models such as 16-bit and 24-bit have become more popular, monitor resolution has also increased. If you have the right hardware and enough memory, you may be able to display 32-bit color on a monitor that is 1600 by 1200 pixels in size for a total memory requirement of 1600 * 1200 * 4 = 7,680,000 bytes, or more than 7MB. |
|
|
|
|
|
|
|
|
Currently the two most popular color modes are 8-bit and 24-bit. This book concentrates mostly on 24-bit color because it is easier to program than the other models. It is also likely to become even more common in the future. It provides enough colors to create images of photographic quality, and it stores information in a format that is easy to use. |
|
|
|
|
|
|
|
|
The gradual decrease in memory prices has left us with a morass of color models, most of which are confusing and hard to use. Because of the simplicity and popularity of 24-bit color, I strongly encourage you to set your computer to 24-bit color mode and use the others as little as possible. |
|
|
|
|
|
|
|
|
Table 3.1 summarizes the most common color models. The third column shows the amount of memory needed to display a 600 by 800 pixel screen in each color model. |
|
|
|
|
|
|
|
|
To make your computer use a certain color model, right-click on an empty part of the desktop and select the Properties command. In the resulting dialog, click the Settings tab. The dialog should be similar to the one shown in Figure 3.1. The dialog's exact appearance depends on your operating system. |
|
|
|
|
|
|
|
|
Using this dialog, you can select the system's color model and monitor resolution. If the dialog includes a Test button on your system, you should test the new configuration before you click the OK or Apply buttons. Testing lets you determine whether your hardware can really support the color model. If you somehow select a mode that your hardware cannot support, you may be stuck with a black monitor. |
|
|
|
|
|